function [shad_all,vis_fl_all,pert_num]=meta_analysis_get_exp_conditions(proj_meta,cur_sites)
shad_all={};
vis_fl_all={};
pert_num={};
for ond=1:length(cur_sites)
    cur_site=cur_sites(ond);
    order={};
    exp_inds={};
    for tnd=1:size(proj_meta(cur_site).rd,2)
        nbr_frames=proj_meta(cur_site).rd(1,tnd).nbr_frames;
        if length(nbr_frames)>5
            for xnd=1:length(nbr_frames)
                if nbr_frames(xnd)==5000
                    if xnd==length(nbr_frames)
                        order{tnd}(xnd)=3;
                    else
                        order{tnd}(xnd)=1;
                    end
                else
                    order{tnd}(xnd)=2;
                end
            end
            ord_ind=1:length(order{tnd});
            order{tnd}(max(ord_ind(order{tnd}==2))+1:end)=3;
        else
            order{tnd}=[1 2 1 2 3];
        end
        exp_inds{tnd}(1,1)=1;
        exp_inds{tnd}(1,2)=nbr_frames(1);
        for fnd=2:length(order{tnd})
            exp_inds{tnd}(fnd,1)=exp_inds{tnd}(fnd-1,2)+1;
            exp_inds{tnd}(fnd,2)=sum(nbr_frames(1:fnd));
        end
    end
    for tnd=1:size(proj_meta(cur_site).rd,2)
        cur_pert_num=[];
        ps_id=proj_meta(cur_site).rd(1,tnd).ps_id;
        runM=proj_meta(cur_site).rd(1,tnd).velM_smoothed>0.005;
        runP=proj_meta(cur_site).rd(1,tnd).velP_smoothed>0.005;
        shad=[];
        vis_fl=[];
        cnt=1;
        for bnd=1:length(order{tnd})
            if order{tnd}(bnd)==1
                tmp_runM=runM(exp_inds{tnd}(bnd,1):exp_inds{tnd}(bnd,2));
                tmp_ps_id=ps_id(exp_inds{tnd}(bnd,1):exp_inds{tnd}(bnd,2));
                for fnd=1:length(tmp_runM)
                    if tmp_runM(fnd)==0
                        shad(cnt)=0;
                        vis_fl(cnt)=0;
                        cnt=cnt+1;
                    elseif tmp_runM(fnd)==1 & logical(tmp_ps_id(fnd))==0 %feedback
                        shad(cnt)=1;
                        vis_fl(cnt)=1;
                        cnt=cnt+1;
                    elseif tmp_runM(fnd)==1 & logical(tmp_ps_id(fnd))==1 %feedback mismatch
                        if tmp_ps_id(fnd)==7
                            shad(cnt)=3;
                            vis_fl(cnt)=0;
                            cnt=cnt+1;
                        else
                            cur_pert_num(cnt)=tmp_ps_id(fnd);
                            shad(cnt)=4;
                            vis_fl(cnt)=1;
                            cnt=cnt+1;
                        end
                    end
                end
            elseif order{tnd}(bnd)==2
                tmp_runM=runM(exp_inds{tnd}(bnd,1):exp_inds{tnd}(bnd,2));
                tmp_ps_id=ps_id(exp_inds{tnd}(bnd,1):exp_inds{tnd}(bnd,2));
                tmp_runP=runP(exp_inds{tnd}(bnd,1):exp_inds{tnd}(bnd,2));
                for fnd=1:length(tmp_runM)
                    if logical(tmp_ps_id(fnd))==0 & tmp_runM(fnd)==0 & tmp_runP(fnd)==0 | logical(tmp_ps_id(fnd))==1 & tmp_runM(fnd)==0 & tmp_runP(fnd)==0
                        shad(cnt)=0;
                        vis_fl(cnt)=0;
                        cnt=cnt+1;
                    elseif logical(tmp_ps_id(fnd))==1 & tmp_runM(fnd)==0 & tmp_runP(fnd)==1
                        if tmp_ps_id(fnd)==7
                            shad(cnt)=5;
                            vis_fl(cnt)=0;
                            cnt=cnt+1;
                        else
                            cur_pert_num(cnt)=tmp_ps_id(fnd);
                            shad(cnt)=6;
                            vis_fl(cnt)=1;
                            cnt=cnt+1;
                        end
                    elseif logical(tmp_ps_id(fnd))==0 & tmp_runM(fnd)==0 & tmp_runP(fnd)==1
                        shad(cnt)=2;
                        vis_fl(cnt)=1;
                        cnt=cnt+1;
                    elseif logical(tmp_ps_id(fnd))==0 & tmp_runM(fnd)==1 & tmp_runP(fnd)==1
                        shad(cnt)=1;
                        vis_fl(cnt)=1;
                        cnt=cnt+1;
                    elseif logical(tmp_ps_id(fnd))==0 & tmp_runM(fnd)==1 & tmp_runP(fnd)==0 | logical(tmp_ps_id(fnd))==1 & tmp_runM(fnd)==1 & tmp_runP(fnd)==0
                        shad(cnt)=7;
                        vis_fl(cnt)=0;
                        cnt=cnt+1;
                    elseif logical(tmp_ps_id(fnd))==1 & tmp_runM(fnd)==1 & tmp_runP(fnd)==1
                        if tmp_ps_id(fnd)==7
                            shad(cnt)=3;
                            vis_fl(cnt)=0;
                            cnt=cnt+1;
                        else
                            cur_pert_num(cnt)=tmp_ps_id(fnd);
                            shad(cnt)=4;
                            vis_fl(cnt)=1;
                            cnt=cnt+1;
                        end
                    end
                end
            end
        end
        shad_all{tnd,ond}=shad;
        vis_fl(length(vis_fl):length(runM))=0;
        vis_fl_all{tnd,ond}=vis_fl;
        cur_pert_num(end+1:length(shad))=0;
        pert_num{tnd,ond}=cur_pert_num;
    end
end